package com.mmall.controller;

import com.mmall.common.ApplicationContextHelper;
import com.mmall.common.JsonData;
import com.mmall.dao.SysAclModuleMapper;
import com.mmall.exception.PermissionException;
import com.mmall.model.SysAclModule;
import com.mmall.param.TestVo;
import com.mmall.util.BeanValidator;
import com.mmall.util.JsonMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @description:
 * @author: mingtai
 * @createDate: 15:51 2020/7/4
 * @version: 1.0
 */

@Controller
@RequestMapping("/test")
@Slf4j
public class TestController {

    @RequestMapping("/hello.json")
    @ResponseBody
    public JsonData hello() {
        log.info("qingqiu coming on");

        throw new RuntimeException("test exception");
//        return JsonData.success("hello success");
    }

    @RequestMapping("/validator.json")
    @ResponseBody
    public JsonData validator(TestVo vo) throws PermissionException{
        log.info("Vo coming on");
        // BeanValidator.check(vo);

        // throw new RuntimeException("test exception");

        SysAclModuleMapper sysAclModuleMapper = ApplicationContextHelper.popBean(SysAclModuleMapper.class);
        SysAclModule module = sysAclModuleMapper.selectByPrimaryKey(1);
        log.info(JsonMapper.obj2String(module));
       return JsonData.success("validator success");
    }


}



